<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改合作伙伴1')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-dept-edit" th:object="${dept}">
            <input name="deptId" th:field="*{deptId}" type="hidden">
            <div class="form-group hidden">
                <label class="col-sm-3 control-label">上级id：</label>
                <div class="col-sm-8">
                    <input name="parentId" th:field="*{parentId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">企业名称：</label>
                <div class="col-sm-8">
                    <input name="deptName" th:field="*{deptName}"  id="deptName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">税号：</label>
                <div class="col-sm-8">
                    <input name="code" th:field="*{code}" id="code" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">负责人：</label>
                <div class="col-sm-8">
                    <input name="leader" th:field="*{leader}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">联系电话：</label>
                <div class="col-sm-8">
                    <input name="phone" th:field="*{phone}" class="form-control" type="text" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">地址：</label>
                <div class="col-sm-8">
                    <input name="address" th:field="*{address}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">邮箱：</label>
                <div class="col-sm-8">
                    <input name="email" th:field="*{email}" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" th:field="*{remark}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "partner/dept";
        $("#form-dept-edit").validate({
            onkeyup: false,
            rules:{
                deptName:{
                    remote: {
                        url: ctx + "partner/dept/checkDeptUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "deptName" : function() {
                                return $.common.trim($("#deptName").val());
                            }
                        }
                    }
                },
                code:{
                    remote: {
                        url: ctx + "partner/dept/checkDeptUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "code" : function() {
                                return $.common.trim($("#code").val());
                            }
                        }
                    }
                },
            },
            messages: {
                "deptName": {
                    remote: "企业名称已经存在"
                },
                "code": {
                    remote: "企业税号已经存在"
                }
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-dept-edit').serialize());
            }
        }
    </script>
</body>
</html>
